package com.example.pinkcat.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import com.example.pinkcat.fragment.Fragment_dongtai;
import com.example.pinkcat.fragment.Fragment_shouye;
import com.example.pinkcat.fragment.Fragment_wode;

public class Shouye_FragmentPagerAdapter extends FragmentPagerAdapter {

    private String[] mItems = new String[]{"首页","动态","投稿","我的"};

    public Shouye_FragmentPagerAdapter(FragmentManager fm){
        super(fm);
    }

    /**
     首页 动态 投稿 我的
     **/
    @NonNull
    @Override
    public Fragment getItem(int position) {
        if (position ==1 ){
            return new Fragment_shouye();
        }else if(position == 2){
            return new Fragment_dongtai();
        }else if(position==3 ){
            return new Fragment_wode();
        }
            return new Fragment_shouye();
    }

    @Override
    public int getCount() {
        return mItems.length;
    }



    //ViewPager与TabLayout绑定后，这里获取到PageTitle就是Tab的Text
    @Override
    public CharSequence getPageTitle(int position){
        return mItems[position];
    }
}
